/**
 * Created by Lcp on 2018/7/14.
 */
var zlbh = window.location.search.split('=');
$.ajax({
    type: 'get',
    cache: false,
    url: baseUrls + 'command/detail/msg',
    data: {
       comid: zlbh[1]
        // /comid: '74589eb4295c41a8972111f66c1aac75'
    },
    beforeSend: function(){
        Loading();
    },
    success: function(response){
        closeLoading();
        if(response.responseCode == '1000'){
            var data = response.content.comandmsg != undefined ? response.content.comandmsg : [],//指令基本信息
                $inputs = document.getElementsByTagName('input'),
                $textarea = document.getElementsByTagName('textarea');
            for(var key in data){
                var value = data[key],
                    input = $inputs[name=''+ key +''] ? $inputs[name=''+ key +''] : '',
                    textarea = $textarea[name=''+ key +''] ? $textarea[name=''+ key +''] : '';
                if(input != ''){
                    if(key == 'comlevel'){
                        if(value == 1){
                            input.value = '高';
                        }else if (value== 2){
                            input.value = '中';
                        }else if (value== 3){
                            input.value = '低';
                        }else{
                            input.value = '未知';
                        }
                    }else if(key == 'comtype'){
                        if(value == 0){
                            input.value = '案件指令';
                        }else if (value== 1){
                            input.value = '线索指令';
                        }else if (value== 2){
                            input.value = '其他指令';
                        }else{
                            input.value = '未知';
                        }
                    }else if(key == 'checkstatus'){
                        if(value == 0){
                            input.value = '未审核';
                        }else if (value== 1){
                            input.value = '通过';
                        }else if (value== 2){
                            input.value = '驳回';
                        }else{
                            input.value = '未知';
                        }
                    }
                    else{
                        input.value = value;
                    }
                }
                if(textarea != ''){
                    textarea.innerHTML = value;
                }
            };
            var ajxx = response.content.comandajxx != undefined  ? response.content.comandajxx : [];//案件基本信息
            $('.ajxxList').html('');
            ajxx.forEach(function(item,index){
                $('.ajxxList').append('<div class="group clearfix"><div class="form-group"><label>案件名称</label><input type="text" class="form-control gxr-hoof" value="'+ nulls(item.eventname) +'" readonly ></div><div class="form-group"><label>案件编号</label><input type="text" class="form-control cjr1-hoof" value="'+ nulls(item.eventid) +'" readonly ></div></div>');
            })

            var comandfileList = response.content.comandfile != undefined  ? response.content.comandfile : [];//附件信息
            $('.comandfileList').html('');
            comandfileList.forEach(function(item,index){
                $('.comandfileList').append('<p><a href="download?url='+ baseUrls + item.wllj + '">'+ nulls(item.filename) +'</a></p>');
            });
        }else{
            Msg();
        }
    },
    error: function(){
        closeLoading();
    }
})